<template>
  <div id="showpop">
       <van-form @submit="createFormData">
        <div v-if="type===1">
          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商业关系</span>
          </div> 
          <van-field :readonly="!canEdit"  name="customerSpecialName" v-model="formdata.customerSpecialName" label="关键和重要客户联系人姓名:" label-width="6.5em" />
          <van-field :readonly="!canEdit"  name="customerSpecialPhone" v-model="formdata.customerSpecialPhone" label="关键和重要客户联系方式:" label-width="6.5em"  type="tel"/>
          <van-field :readonly="!canEdit"  name="customerHobby" v-model="formdata.customerHobby" label="个人偏好:" label-width="4.5em" />
          <van-field :readonly="!canEdit"  name="customerProjectHobby" v-model="formdata.customerProjectHobby" label="项目偏好:" label-width="4.5em" />
          <van-field :readonly="!canEdit"  name="customerRecord" v-model="formdata.customerRecord" label="客户内部动态记录:" label-width="8.5em" />

          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商机进展</span>
          </div> 
          <van-field :readonly="!canEdit"  name="businessBackground" v-model="formdata.businessBackground" label="商机基础背景:" label-width="6.5em" />
          <van-field :readonly="!canEdit"  name="customerDemand" v-model="formdata.customerDemand" label="客户需求:" label-width="4.5em" />
          <van-field readonly  name="predictSignTime" v-model="formdata.predictSignTime" label="预计签约时间:" label-width="6.5em" 
            placeholder="请选择" @click="canEdit ? showDateDialog = true : '' "/>
          <van-field :readonly="!canEdit"  name="businessMaking" v-model="formdata.businessMaking" label="商机决策链条和进度:" label-width="9.5em"/>
          <van-cell center title="商机进度记录和重要过程文件" style="color: #999;">
            <template #default v-if="canEdit">
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.businessScheduleFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.businessScheduleFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.businessScheduleFileList,index)"></van-icon>
          </div>
        </div>

        <div v-else-if="type===2">
          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商业关系</span>
          </div> 
          <van-field :readonly="!canEdit" name="tenderingAgency" v-model="formdata.tenderingAgency" label="招标代理机构名称:" label-width="8.5em" />
          
          <van-cell center title="合作伙伴" style="color: #999;">
            <template #default v-if="canEdit">
                <van-button size="small" type="primary" native-type='button' @click.stop="addItemFromOtherPage">新增</van-button>
            </template>
          </van-cell>
          <el-table  :data="formdata.partnerList" border style="width: 100%">
            <el-table-column prop="partnerCode" label="合作伙伴编码"/>
            <el-table-column prop="partnerName" label="合作伙伴名称"/>
            <el-table-column prop="cooperationType" label="合作类型"/>
            <el-table-column prop="city" label="地市"/>
            <el-table-column prop="partnerAbbreviation" label="合作伙伴简称"/>
            <el-table-column prop="companyAddress" label="公司地址"/>
            <el-table-column label="操作" v-if="canEdit">
              <template slot-scope="scope">
                <el-button
                  size="mini" type="danger" @click="deleteTableItem(formdata.partnerList,scope.$index)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        
          <van-cell center title="评审专家" style="color: #999;">
            <template #default v-if="canEdit">
                <van-button size="small" type="primary" native-type='button' @click.stop="addItemFromInputDialog">新增</van-button>
            </template>
          </van-cell>
          <el-table  :data="formdata.expertList" border style="width: 100%">
            <el-table-column prop="expertName" label="评审专家姓名"/>
            <el-table-column prop="expertContact" label="评审专家联系方式"/>
            <el-table-column label="操作" v-if="canEdit">
              <template slot-scope="scope">
                <el-button
                  size="mini" type="danger" @click="deleteTableItem(formdata.expertList,scope.$index)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <van-field :readonly="!canEdit"   name="ecologicalRelation" v-model="formdata.ecologicalRelation" label="生态商业关系评价:" label-width="8.5em" />
          <van-field :readonly="!canEdit"   name="ecologicalRecord" v-model="formdata.ecologicalRecord" label="生态商业动态记录:" label-width="8.5em" />

          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商机进展</span>
          </div> 
          <van-cell center title="生态方案" style="color: #999;">
            <template #default v-if="canEdit">
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ecologicalPlanFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ecologicalPlanFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ecologicalPlanFileList,index)"></van-icon>
          </div>

          <van-cell center title="资质" style="color: #999;">
              <template #default v-if="canEdit" >
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ecologicalSeniorityFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ecologicalSeniorityFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ecologicalSeniorityFileList,index)"></van-icon>
          </div>

          <van-field :readonly="!canEdit"   name="ecologicalAbility" v-model="formdata.ecologicalAbility" label="项目经验能力评价:" label-width="8.5em" />

          <van-cell center title="生态项目过程记录" style="color: #999;">
              <template #default v-if="canEdit" >
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ecologicalRecordFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ecologicalRecordFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ecologicalRecordFileList,index)"></van-icon>
          </div>
          <van-cell center title="生态项目重要过程文件" style="color: #999;">
              <template #default v-if="canEdit" >
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ecologicalProcessFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ecologicalProcessFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ecologicalProcessFileList,index)"></van-icon>
          </div>
        </div>

        <div v-else-if="type===3">
          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商业关系</span>
          </div> 
        
          <van-cell center title="竞争对手" style="color: #999;">
            <template #default v-if="canEdit">
                <van-button size="small" type="primary" native-type='button' @click.stop="addItemFromInputDialog">新增</van-button>
            </template>
          </van-cell>
          <el-table  :data="formdata.competitorList" border style="width: 100%">
            <el-table-column prop="competeName" label="竞争对手姓名"/>
            <el-table-column prop="competePhone" label="竞争对手联系方式"/>
            <el-table-column prop="competeRecord" label="竞争对手商业动态记录"/>
            <el-table-column label="操作" v-if="canEdit">
              <template slot-scope="scope">
                <el-button
                  size="mini" type="danger" @click="deleteTableItem(formdata.competitorList,scope.$index)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>

          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商机进展</span>
          </div> 
          <van-cell center title="竞争对手方案" style="color: #999;">
            <template #default v-if="canEdit">
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.competePlanFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.competePlanFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.competePlanFileList,index)"></van-icon>
          </div>
          <van-cell center title="资质" style="color: #999;">
            <template #default v-if="canEdit" >
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.competeSeniorityFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.competeSeniorityFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.competeSeniorityFileList,index)"></van-icon>
          </div>

          <van-field :readonly="!canEdit"   name="competeAbility" v-model="formdata.competeAbility" label="项目经验能力评价:" label-width="8.5em" />
          <van-cell center title="竞争对手项目过程记录" style="color: #999;">
            <template #default v-if="canEdit">
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.competeRecordFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.competeRecordFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.competeRecordFileList,index)"></van-icon>
          </div>
          <van-cell center title="竞争对手项目重要过程文件" style="color: #999;">
            <template #default v-if="canEdit">
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.competeProcessFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.competeProcessFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.competeProcessFileList,index)"></van-icon>
          </div>
          
        </div>

        <div v-else>
          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商业关系</span>
          </div> 
          <van-field :readonly="!canEdit"   name="relationEvaluation" v-model="formdata.relationEvaluation" label="我司商业关系评价:" label-width="8.5em" />
          <van-field :readonly="!canEdit"   name="relationRecord" v-model="formdata.relationRecord" label="首席代表商业动态记录:" label-width="6.5em" />
          <van-field :readonly="!canEdit"   name="relationOrdinary" v-model="formdata.relationOrdinary" label="普通商业动态记录:" label-width="8.5em" />
          <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
              <div class="blue_item"></div>
              <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商机进展</span>
          </div> 
          <van-cell center title="移动方案" style="color: #999;">
            <template #default v-if="canEdit">
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ourPlanFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ourPlanFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ourPlanFileList,index)"></van-icon>
          </div>
          <van-cell center title="资质" style="color: #999;">
            <template #default v-if="canEdit" >
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ourSeniorityFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ourSeniorityFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ourSeniorityFileList,index)"></van-icon>
          </div>

          <van-field :readonly="!canEdit"   name="ourAbility" v-model="formdata.ourAbility" label="项目经验能力评价:" label-width="8.5em" />
          <van-cell center title="移动项目过程记录" style="color: #999;">
            <template #default v-if="canEdit">
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ourRecordFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ourRecordFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ourRecordFileList,index)"></van-icon>
          </div>
          <van-cell center title="移动项目重要过程文件" style="color: #999;">
            <template #default v-if="canEdit" >
                  <van-uploader :after-read="(file) => uploadFileToServer(formdata.ourProcessFileList,file)">
                      <van-button size="small" icon="plus" type="primary">上传附件</van-button>
                  </van-uploader>
              </template>
          </van-cell>
          <div v-for="(fileitem, index) in formdata.ourProcessFileList" :key="fileitem.id" style="margin-left:20px">
              <div readonly class="font14 fileLink" style="color:#0F85CF">
                  <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
              </div>
              <van-icon v-if="canEdit" name="close" color="#ea0023" size="20" @click="deleteFile(formdata.ourProcessFileList,index)"></van-icon>
          </div>
         
        </div>

        <div  class="footer" v-if="canEdit">
          <van-button block type="info" native-type="submit"
            style="display: inline-block;width:100%;border: 15px solid #60a9ec;">新增
          </van-button>
        </div>
        <van-popup v-model="showDateDialog" position="bottom" get-container="#showpop">
            <van-datetime-picker :formatter="formatter" type="date"  @cancel="showDateDialog = false" @confirm="showDateDialogComfirm" />
        </van-popup>
      </van-form>
      <van-popup v-model:show="showInputPop" round :style="{ padding: '10px',width: '80%',}">
          <van-field input-align='left' label-width="6.5em" v-model="inputValue1" :label="inputLabel1" right-icon="arrow"/>
          <van-field input-align='left' label-width="8.5em" v-model="inputValue2" :label="inputLabel2" right-icon="arrow"  type="tel"/>
          <van-field v-if="inputLabel3!=''" input-align='left' label-width="8.5em" v-model="inputValue3" :label="inputLabel3" right-icon="arrow"/>
          <div style="display: flex;justify-content: center;">
              <van-button size="small" style="width: 50%;margin-top: 10px;"
              @click="onClickSureInputDialog" type="primary" color="#60a9ec">确定</van-button>
          </div>
      </van-popup>
    <selectListPage  v-if="showSelectPage" v-on:update-flag="showSelectPage=false" v-on:select-item="handleSelectItem"
                     :pageTitle="'选择合作伙伴'" :url="'partnerBasic$api$findAll'"
                     :bodyParam="{}" :queryParam="{}"
                     :listShow="[{ 'key':'partnerName'},{ 'key':'partnerCode', 'prefix':'合作伙伴编码'}]">
    </selectListPage>
  </div>
</template>

<script>
import { openFileUrl } from "@/store/openFile";
import {mapGetters} from "vuex"
import { Notify,Dialog, Toast } from 'vant'
import { uploadFileCommon , getSrqrRequest} from "@/api/dictapi";
import util from "@/assets/js/public";
import moment from 'moment'
import myvan_field from '@/components/myvanfield';
import selectListPage from '@/views/common/page_normal_select_list';
  export default {
    components:{
      myvan_field,selectListPage
    },
    data() {
      return {
        formdata:{},  
        type:1,
        typeValue:"",
        canEdit:false,
        showInputPop:false,
        showDateDialog:false,
        inputLabel1:"",
        inputLabel2:"",
        inputLabel3:"",
        inputValue1:"",
        inputValue2:"",
        inputValue3:"",
        showSelectPage:false
      }
    },
    computed:{
        ...mapGetters(['user']),
        ...mapGetters(['userinfo'])
    },
    beforeRouteLeave(to, from, next) {
      if(to.name =="sjwhdetail"){//返详情需要清空数据
        this.formdata={}
        this.type=1
        this.typeValue=""
        this.canEdit=false
        this.showInputPop=false
        this.showDateDialog=false
        this.inputLabel1=""
        this.inputLabel2=""
        this.inputLabel3=""
        this.inputValue1=""
        this.inputValue2=""
        this.inputValue3=""
      }
    next();
  },
    activated() { //三种情况，1\首次进入起草、2\首次进入查看、3\选择数据返回
      if(Object.keys(this.formdata).length === 0){//1、2
        this.initData()
      }
    },
    //方法调用
    methods: {
      initData(){
        this.canEdit=!this.$route.params.datas;
        this.formdata = this.$route.params.datas ? this.$route.params.datas : {
            businessId:"",
            businessScheduleFileList:[],
            ecologicalPlanFileList:[],
            ecologicalSeniorityFileList:[],
            ecologicalRecordFileList:[],
            ecologicalProcessFileList:[],
            partnerList:[],
            expertList:[],
            competitorList:[],
            competePlanFileList:[],
            competeSeniorityFileList:[],
            competeRecordFileList:[],
            competeProcessFileList:[],
            ourPlanFileList:[],
            ourSeniorityFileList:[],
            ourRecordFileList:[],
            ourProcessFileList:[]
          }
        this.type=this.$route.params.type;
        const businessId=this.$route.params.businessId;
        switch(this.type){
            case 1:this.typeValue="customerSide";
            break;
            case 2: this.typeValue="ecologicalSide";
            break;
            case 3: this.typeValue="competitiveSide";
            break;
            default:this.typeValue="movingSide";
            break;
        }    
        this.formdata.businessId=businessId;
        if(this.canEdit){
            this.getdetail(this.typeValue,businessId);
        }
      },
      formatter(type, val) {
          if (type === 'year') {
              return `${val}年`;
          } else if (type === 'month') {
              return `${val}月`;
          } else if (type === 'day') {
              return `${val}日`;
          } else if (type === 'hour') {
              return `${val}时`;
          } else if (type === 'minute') {
              return `${val}分`;
          }
          return val;
      },
      showDateDialogComfirm(value){
        this.showDateDialog = false;
        this.formdata.predictSignTime= moment(value).format('YYYY-MM-DD')
      },
      openFileUrlfun(value) {
            this.$router.push({
                name: "fileview",
                query: {
                    openFileUrl: openFileUrl(value),
                },
            });
        },
      handleSelectItem(selectMap){
        this.showSelectPage=false;
        if(!this.formdata.partnerList){
          this.formdata.partnerList=[]
        }
        this.formdata.partnerList.push({
          partnerName:selectMap.partnerName,
          partnerCode:selectMap.partnerCode,
          city:selectMap.city,
          cooperationType:selectMap.cooperationType,
          partnerAbbreviation:selectMap.partnerAbbreviation,
          companyAddress:selectMap.companyAddress
        })
        this.$forceUpdate();
      },
      addItemFromOtherPage(){
        this.showSelectPage=true
      },
      addItemFromInputDialog(){
        this.showInputPop=true;
        if(this.type==2){
            this.inputLabel1="评审专家姓名:"
            this.inputLabel2="评审专家联系方式:"
        }else{
            this.inputLabel1="竞争对手姓名:"
            this.inputLabel2="竞争对手联系方式:"
            this.inputLabel3="竞争对手商业动态记录:"
        }
      },
      onClickSureInputDialog(){
        if(this.inputValue2){
            const phonePass=this.newUtils.isPhoneNumber(this.inputValue2)
            if(!phonePass){
              Notify("请输入正确的手机号码");
              return
            }
        }
        this.showInputPop=false;
        if(this.type==2){
           if(!this.formdata.expertList){
             this.formdata.expertList=[];
           }
            this.formdata.expertList.push({
                "expertName":this.inputValue1,
                "expertContact":this.inputValue2
            })
        }else{
            if(!this.formdata.competitorList){
             this.formdata.competitorList=[];
           }
            this.formdata.competitorList.push({
                "competeName":this.inputValue1,
                "competePhone":this.inputValue2,
                "competeRecord":this.inputValue3
            })
        }
        this.inputValue1="";
        this.inputValue2="";
        this.inputValue3="";
      },
      getdetail(typeValue,bId){
          Toast.loading({
              message:'加载中',
              forbidClick:false
          });
          getSrqrRequest("customerSide$api$querySideByTime",{
              kv: {
                "type": typeValue,
                "source": 'MOBILE',
                "businessId":bId,
                "currentUserCode": util.encrypt(this.user.userName),
              }
            }) .then((result)=>{
                Toast.clear();
                if(result.data.data){
                    const originalData = this.formdata;
                    const newData = result.data.data;
                    this.formdata = Object.assign({}, originalData, {
                      "ecologicalAbility" : newData.ecologicalAbility,
                      "ecologicalPlanFileList" : newData.ecologicalPlanFileList,
                      "ecologicalProcessFileList" : newData.ecologicalProcessFileList,
                      "ecologicalRecord" : newData.ecologicalRecord,
                      "ecologicalRecordFileList" : newData.ecologicalRecordFileList,
                      "ecologicalRelation" : newData.ecologicalRelation,
                      "ecologicalSeniorityFileList" : newData.ecologicalSeniorityFileList,
                      "expertList" : newData.expertList,
                      "partnerList" : newData.partnerList,
                      "tenderingAgency" : newData.tenderingAgency,
                      "expertName" : newData.expertName,
                      "expertContact" : newData.expertContact
                    });
                }
            })
            .catch(() => { Toast.clear();});
        },
      uploadFileToServer(list,file) {
        Toast.loading({
            message:'加载中',
            forbidClick:false
        });
        let fileData = new FormData();
        fileData.append("pmInsType", "XF");
        fileData.append("pmInsTypePart", "1");
        fileData.append("files", file.file);

        let params = new Map();
        params.pmInsType = "aaa";
        params.pmInsTypePart = '1';
        params.userName = this.user.userName;
        uploadFileCommon(fileData, params).then((res) => {
            Toast.clear();
            if (!res.data) {
                Notify(res.message);
                return;
            }
            if (res.data.data) {
                list.push(res.data.data.sysFiles[0]);
            }
        })
        .catch(() => { Toast.clear();});
      },

      deleteFile(list,index) {
        Dialog.confirm({ title: "提示", message: "是否删除此附件？" })
            .then(() => {
              list.splice(index, 1);
            })
            .catch(() => { });
      },
      deleteTableItem(list,index) { //delete from data
          Dialog.confirm({
            title: '提示',
            message: '是否删除此条数据？'
          }).then(() => {
            list.splice(index,1)
          })
          .catch(() => {
          })
        },
      createFormData(){ //提交流转.customerSpecialPhone
          if(this.formdata.customerSpecialPhone){
              const phonePass=this.newUtils.isPhoneNumber(this.formdata.customerSpecialPhone)
              if(!phonePass){
                Notify("请输入正确的手机号码");
                return
              }
          }
       
          Toast.loading({
              message:'加载中',
              forbidClick:false
          });
          var url=""
          switch(this.typeValue){
            case "customerSide":
              url="customerSide$api$createCustomerSide";
            break;
            case "ecologicalSide": 
             url="ecologicalSide$api$createEcologicalSide";
            break;
            case "competitiveSide": 
              url="competitiveSide$api$createCompetitiveSide";
            break;
            default:
              url="movingSide$api$createMovingSide";
            break;
        }    
          getSrqrRequest(url,{
              "kv": {
                "source": 'MOBILE',
                "currentUserCode": util.encrypt(this.user.userName),
              },
              "body": Object.assign({}, this.formdata)
            }) .then((result)=>{
                  Toast.clear();
                  if(result.responseid==1){//请求成功
                    this.$router.go(-1);
                    localStorage.setItem('bus_refresh_table', this.typeValue);
                  }else{
                    Notify(result.message);
                  }
            })
            .catch(() => { Toast.clear();});
      }
    }
  }
</script>
<style  scoped>
</style>